package com.ruoyi.web.controller.system;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizSendGas;
import com.ruoyi.system.service.IBizSendGasService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 送气记录Controller
 * 
 * @author feng.gao
 * @date 2025-04-28
 */

@Controller
@RequestMapping("/system/send")
public class BizSendGasController extends BaseController
{
    private String prefix = "system/send";

    @Autowired
    private IBizSendGasService bizSendGasService;

    @RequiresPermissions("system:send:view")
    @GetMapping()
    public String send()
    {
        return prefix + "/send";
    }

    /**
     * 查询送气记录列表
     */
    @RequiresPermissions("system:send:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizSendGas bizSendGas)
    {
        startPage();
        List<BizSendGas> list = bizSendGasService.selectBizSendGasList(bizSendGas);
        return getDataTable(list);
    }

    /**
     * 导出送气记录列表
     */
    @RequiresPermissions("system:send:export")
    @Log(title = "送气记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizSendGas bizSendGas)
    {
        List<BizSendGas> list = bizSendGasService.selectBizSendGasList(bizSendGas);
        ExcelUtil<BizSendGas> util = new ExcelUtil<BizSendGas>(BizSendGas.class);
        return util.exportExcel(list, "送气记录数据");
    }

    /**
     * 新增送气记录
     */

    @RequiresPermissions("system:send:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存送气记录
     */

    @RequiresPermissions("system:send:add")
    @Log(title = "送气记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizSendGas bizSendGas)
    {
        return toAjax(bizSendGasService.insertBizSendGas(bizSendGas));
    }

    /**
     * 修改送气记录
     */
    @RequiresPermissions("system:send:edit")
    @GetMapping("/edit/{sn}")
    public String edit(@PathVariable("sn") Long sn, ModelMap mmap)
    {
        BizSendGas bizSendGas = bizSendGasService.selectBizSendGasBySn(sn);
        mmap.put("bizSendGas", bizSendGas);
        return prefix + "/edit";
    }

    /**
     * 修改保存送气记录
     */
    @RequiresPermissions("system:send:edit")
    @Log(title = "送气记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizSendGas bizSendGas)
    {
        return toAjax(bizSendGasService.updateBizSendGas(bizSendGas));
    }

    /**
     * 删除送气记录
     */
    @RequiresPermissions("system:send:remove")
    @Log(title = "送气记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizSendGasService.deleteBizSendGasBySns(ids));
    }
}
